//
//  XS_DownloadStartBottomView.swift
//  XueDao
//
//  Created by Mac on 2021/1/9.
//

import UIKit

protocol XS_CouponBottomViewDelegate {
    func bottomView(bottomView : XS_CouponBottomView, didClickOperateBtn:UIButton)
}

class XS_CouponBottomView: UIView {
    
    
    var delegate : XS_CouponBottomViewDelegate?
    
    lazy var allLabel : UILabel = {
        let allLabel = UILabel.init(frame: .zero)
        allLabel.font = .systemFont(ofSize: 14)
        allLabel.textColor = UIColor.qmui_color(withHexString: "383C3F")
        return allLabel
    }()
    
    lazy var operateBtn : UIButton = {
        let operateBtn = UIButton.init(frame: .zero)
        operateBtn.backgroundColor = #colorLiteral(red: 0.768627451, green: 0.7764705882, blue: 0.8039215686, alpha: 1)
        operateBtn.layer.cornerRadius = 20
        operateBtn.clipsToBounds = true
        operateBtn.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
        operateBtn.setTitleColor(.white, for: .normal)
        operateBtn.setTitle("确认使用", for: .normal)
        operateBtn.addTarget(self, action: #selector(operateBtnAction(_:)), for: .touchUpInside)
        return operateBtn
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = .white
        addSubview(allLabel)
        addSubview(operateBtn)
        
        allLabel.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(17)
            make.top.equalToSuperview().offset(10)
        }
        
        operateBtn.snp.makeConstraints { (make) in
            make.size.equalTo(CGSize.init(width: 98, height: 40))
            make.right.equalToSuperview().offset(-16)
            make.top.equalToSuperview().offset(4.5)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    @objc func operateBtnAction(_ sender: UIButton) {
        if delegate != nil {
            delegate?.bottomView(bottomView: self, didClickOperateBtn: sender)
        }
    }
}
